package server

import (
	"github.com/go-kratos/kratos/v2/middleware/recovery"
	"github.com/go-kratos/kratos/v2/transport/grpc"
	v1 "go-mall/api/goodsserver/v1"
	"go-mall/app/goodsserver-svc/internal/service"
	"time"
)

func NewGRPCServers(service *service.GoodsService) *grpc.Server {
	var (
		opts = []grpc.ServerOption{
			grpc.Middleware(
				recovery.Recovery(),
			),
		}
	)
	opts = append(opts, grpc.Timeout(time.Second*5))
	srv := grpc.NewServer(opts...)
	v1.RegisterGoodsServer(srv, service)
	return srv
}
